<template>
  <d2-container >

    <el-dialog
    title="更新学生状态"
    :visible.sync="dialogVisibleStatus"
    width="30%"
    >
    <span>选择出勤状态</span>
    <el-select v-model="dialog_status" placeholder="请选择" style="margin-top:3vw">
      <el-option
      v-for="item in option.studentRecordStatus"
      :key="item.value"
      :label="item.name"
      :value="item.value">
    </el-option>
  </el-select>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisibleStatus = false">取 消</el-button>
    <el-button type="primary" @click="updateStudentRecord">确 定</el-button>
  </span>

</el-dialog>

    <el-dialog
    title="新备注消息"
    :visible.sync="showMessage"
    width="40%"
    >
  <textarea v-model='message' style="width: 100%;min-height: 200px"></textarea>
  <span slot="footer" class="dialog-footer">
    <el-button @click="showMessage = false">取 消</el-button>
    <el-button type="primary" @click="newMessage">确 定</el-button>
  </span>

</el-dialog>


    <el-dialog
    title="新学习计划"
    :visible.sync="showPlan"
    width="30%"
    >
  <textarea v-model='plan' style="width: 100%;min-height: 400px"></textarea>
  <span slot="footer" class="dialog-footer">
    <el-button @click="showPlan = false">取 消</el-button>
    <el-button type="primary" @click="newStudyPlan">确 定</el-button>
  </span>

</el-dialog>


<el-dialog
title="转班"
:visible.sync="dialogVisibleChangeClass"
width="30%"
>

<span>要离开的班级:</span>
<el-select v-model="classInName" placeholder="请选择要离开的班级" style="margin-top:3vw;margin-left: 3vw" :disabled='true'>
  <el-option
  v-for="item in option.classInOption"
  :key="item._id"
  :label="item.name"
  :value="item._id"
  >
</el-option>
</el-select>
<br>

<span>请选择要转入的班级:</span>
<el-select v-model="class_ready_in" placeholder="请选择要转入的班级" style="margin-top:3vw;margin-left: 3vw">
  <el-option
  v-for="item in option.classChangeOption"
  :key="item._id"
  :label="item.name"
  :value="item._id">
</el-option>
</el-select>
<span slot="footer" class="dialog-footer">

  <el-button @click="dialogVisibleChangeClass = false">取 消</el-button>

  <el-button type="primary" @click="moveStudentToOtherClass">确 定</el-button>
</span>
</el-dialog>


<el-dialog
title="转课"
:visible.sync="dialogVisibleChangeCourse"
width="40%"
>
<div>
  <span style="display: inline-block;width: 60px">转出课程:</span>
  <el-select v-model="courseOut.nameText" placeholder="转出课程" style="margin-top:0vw;margin-left: 10px;display: inline-block;width: 170px" :disabled='true'>

  </el-select>

  <span style="display: inline-block;margin-left:20px;width: 60px">转出班级:</span>
  <el-select v-model="courseOut.class.name" placeholder="转出班级" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:170px" :disabled='true'>

  </el-select>
</div>
<div style="margin-top: 20px">
  <span style="display: inline-block;width: 60px">转入课程:</span>
  <el-select v-model="courseTransferIndex" placeholder="转入课程" style="margin-top:0vw;margin-left: 10px;display: inline-block;width: 170px" @change='changeCourseSelect'>
    <el-option
    v-for="(item ,index) in courseTransferList"
    :key="index"
    :label="item.name + '(' + item.duration + '小时)'"
    :value="index">
  </el-option>
</el-select>

<span style="display: inline-block;margin-left:20px;width: 60px">转入班级:</span>
<el-select v-model="courseTransfer.class" placeholder="转入班级" style="margin-top:0vw;margin-left: 10px;display: inline-block;width:170px" >
  <el-option
  v-for="item in courseTransferClassList"
  :key="item._id"
  :label="item.name"
  :value="item._id"
  >
</el-option>
</el-select>
</div>
<br>
<!-- v-if="courseTransfer != undefined" -->
<div >
  <span style="display: inline-block;width: 60px;font-size: 12px">原收费方式</span>
  <el-input v-model="courseOut.typeText" placeholder="收费方式" style="margin-top:0vw;margin-left: 10px;display: inline-block;width: 170px" :disabled='true'>
  </el-input>

  <span style="display: inline-block;margin-left:20px;width: 60px;">剩余</span>
  <el-input v-model="courseOut.leftAmount" placeholder="剩余课时" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:140px" :disabled='true'>
  </el-input>
  <span v-if='courseOut.type == 0' style="margin-left:5px">课时</span>
  <span v-if='courseOut.type == 1' style="margin-left:5px">小时</span>
  <span v-if='courseOut.type == 2' style="margin-left:5px">月</span>
</div>

<div style="margin-top: 10px">
  <span style="display: inline-block;width: 60px;font-size: 12px;">新收费方式</span>
  <el-select v-model="courseTransfer.type" placeholder="收费方式" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:170px" @change='hahaha'>
    <el-option
    v-for="item in courseTransfer.pays"
    :key="item.type"
    :label="item.name"
    :value="item.type"
    >
  </el-option>
</el-select>

<span style="display: inline-block;margin-left:20px;width: 60px;margin-top:10px">换算</span>
<el-input v-model="courseTransfer.numberTotal" placeholder="换算课时" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:140px"  @input="changeCourseAmount($event)" type='number' min='0' step='1'>
</el-input>
<span v-if='courseTransfer.type == 0' style="margin-left:5px">课时</span>
<span v-if='courseTransfer.type == 1' style="margin-left:5px">小时</span>
<span v-if='courseTransfer.type == 2' style="margin-left:5px">月</span>
</div>    

<div style="margin-top: 10px">
  <span style="display: inline-block;width: 60px;">优惠(元)</span>
  <el-input v-model="courseTransfer.discount" placeholder="优惠" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:170px" @input="changeCourseDiscount($event)" type='number' min='0'>
  </el-input>      
  <span style="display: inline-block;width: 60px;margin-left: 20px">补价(元)</span>
  <el-input v-model="courseTransfer.profit" placeholder="差价(元)" style="margin-top:0vw;margin-left: 10px;display: inline-block;;width:170px" :disabled='true'>
  </el-input>  

</div>     

<span slot="footer" class="dialog-footer">

  <el-button @click="cancelChangeCourse">取 消</el-button>

  <el-button type="primary" @click="changeCourseConfirm">确 定</el-button>
</span>
</el-dialog>


<el-dialog
title="退款"
:visible.sync="reimbursedialogShow"
width="40%"
>

<div style="margin-top: 10px">
  <div>
    <div v-for='item in courseOrder' style="margin-bottom: 5px">

      <div style="width: 150px;display: inline-block;">课程：{{item.course.name}}</div>
      <div style="width: 150px;display: inline-block">班级：{{item.class.name}}</div>
      <div style="width: 150px;display: inline-block">付费方式：{{item.classType}}</div>
      <div style="width: 150px;display: inline-block">购买数量：{{item.numberTotal}}</div>
      <div style="width: 150px;display: inline-block">剩余数量：{{item.amountx}}</div>
      <div style="width: 150px;display: inline-block">课程单价：{{item.unitPrice}}元</div>
      <div style="width: 150px;display: inline-block">优惠：{{item.discount}}元</div>
      <div style="width: 150px;display: inline-block">订单金额：{{item.total - item.discount}}元</div>
    </div>
  </div>
  <span style="display: inline-block;width: 60px;margin: 20px;margin-top: 25px">退款(元):</span>
  <el-input v-model="reimburseAmount" placeholder="退款(元)" style="margin-top:25px;margin-left: 0px;display: inline-block;width:170px" >
  </el-input>  
</div>     

<span slot="footer" class="dialog-footer">

  <el-button @click="reimburseCancel">取 消</el-button>

  <el-button type="primary" @click="reimburseConfirm">确 定</el-button>
</span>
</el-dialog>


<el-dialog
title="学生状态改变"
:visible.sync="dialogStudentStatus"
width="30%"
>
<span>确定要{{student.status == 0 ? '停课吗？' : '恢复上课吗？'}}</span>
<span slot="footer" class="dialog-footer">


  <el-button @click="dialogStudentStatus = false">取 消</el-button>

  <el-button type="primary" @click="studentStatusChange">确 定</el-button>

</span>
</el-dialog>


<el-dialog
title="退出班级"
:visible.sync="dialogVisibleRemoveClass"
width="30%"
>
<span>请选择要退出的班级</span>

<el-select v-model="class_ready_leave" placeholder="请选择要离开的班级" style="margin-top:3vw">
  <el-option
  v-for="item in option.classInOption"
  :key="item._id"
  :label="item.name"
  :value="item._id"
  >
</el-option>
</el-select>
<span slot="footer" class="dialog-footer">
  <el-button @click="dialogVisibleRemoveClass = false">取 消</el-button>
  <el-button type="primary" @click="exitFromClass">确 定</el-button>
</span>
</el-dialog>


<div style="position: relative;">
  <el-button style='position: absolute;top:10px;right:0px;z-index: 100' @click='addParentTab'>添加家长</el-button>
<el-tabs type="card" editable  v-model="paneChose" @edit="handleTabsEdit" >
  <el-tab-pane label="学生信息" name='studentInfo'>
    <el-main>
      <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;'>
        <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
        <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
        <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
        在读课程： {{courseCount}}</div>
        <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
          <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
        在读校区:  {{student.school.name}}</div>
        <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
          <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
        联系方式： {{parentInfo}}</div>
        <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">

    <el-button @click="updateStudentNewStudent" type="primary" v-if='!student.newStudent == 1'>确认转卡</el-button>
        </el-button>
          <el-button @click="reimbursedialog" type="primary" v-if='(student.status == 1) || (student.quit == 1)'>退款</el-button>
        </el-button>
        </el-button>
          <el-button @click="removeFromClass" type="primary" v-if='student.status == 0'>退学</el-button>
        </el-button>
        <el-button @click="restoreStudent" type="warning" v-if='(student.status == 1) || (student.quit == 1)'>复课</el-button>
      </el-button>
    </div>
  </el-row>

  <!-- <block name="courseList"> -->
    <el-row :span="6" style="margin-top:10px;height:40px"><span style='width:2px;height:100%;background-color:rgb(52, 178, 211) ;color: rgb(52, 178, 211);margin-right: 3px'>_</span>课程信息
      <el-button @click="buyOrder" type='primary' style='height:30px;position: relative;top:0px;font-size: 14px;padding: 5px;margin-left:50px;' :disabled="student.status == 1">购买课程
      </el-button>


    </el-row>
    <el-row v-if="courseOrder.length == 0" style='background-color: white;height:300px'>
      <div style="color:#CACBCC;width: 100%;text-align: center;line-height: 300px;height: 300px">请点击左上方按钮报名课程</div>
    </el-row>

    <el-row style='background-color:white;width: 100%;height:280px;position: relative;border-width: 1px;border-color: #D4DFE5;border-style: solid;margin-bottom:20px' v-for='(order,index) in courseOrder'  >


      <div style="background-color:#F6FAFE;height:60px;width:100%;z-index: 1000">
        <div style="display: inline-block;font-size:15px;width: 300px"> <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px;margin-top:13px;margin-left: 15px">课</span> 
          {{courseOrder[index].course.name}}


        </div>
        <div style="display: inline-block;font-size:15px;width: 250px;">
          <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
          {{courseOrder[index].course.school.name}}
          <!-- 总校区 -->
        </div>

        <div style="display: inline-block;font-size:15px;width: 350px">
         <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">班</span>

         {{courseOrder[index].class.name}}
       </div>

     </div>

     <div style="width: 100%;position: relative;height: 1px;background-color: #D4DFE5">
     </div>

     <div style="width: 100%;position: relative;z-index: 0">
      <div style="position: relative;left:30px;top:20px;color:#98A0A7;display: inline-block;width: 200px">收费模式 : 
        <span v-if="order.type == 0">课时</span>
        <span v-if='order.type == 1'>小时</span>
        <span v-if='order.type == 2'>包月</span>
      </div>
      <div style="position: relative;left:105px;top:20px;color:#98A0A7;display: inline-block;width: 100px">剩余 :</div>

      <el-input style="position: relative;left:70px;top:20px;display: inline-block;width: 100px" v-model='order.numberOfClasses' type="number" min="0" :disabled='true' v-if="order.type == 0">
      </el-input>
      <el-input style="position: relative;left:70px;top:20px;display: inline-block;width: 100px" v-model='order.numberOfHours' type="number" min="0" :disabled='true' v-if="order.type == 1">
      </el-input>
      <el-input style="position: relative;left:70px;top:20px;display: inline-block;width: 100px" v-model='order.numberOfMonths' type="number" min="0" :disabled='true' v-if="order.type == 2">
      </el-input>
      <div style="position: relative;left:80px;top:20px;color:#98A0A7;display: inline-block;width: 200px">
        <span v-if="order.type == 0">课时</span>
        <span v-if='order.type == 1'>小时</span>
        <span v-if='order.type == 2'>月</span>
      </div>
    </div>

    <div style="width: 100%;position: relative;height: 1px;background-color: #D4DFE5;top:40px">
    </div>

    <div style="width: 100%;position: relative;top:40px">


      <el-checkbox v-model="order.valid" style='display: inline-block;position: relative;top:20px;margin-left:15px;font-size: 18px' :disabled='true'>有效期</el-checkbox>
      <el-date-picker
      v-model="order.validDate"
      type="date"
      placeholder="选择截止有效期"
      :disabled="true"
      style='position: relative;top:20px;left:10px'
      ></el-date-picker>

      <div style="display: inline-block;" v-if='order.type == 2'>
        <div style="position: relative;left:50px;top:20px;color:#98A0A7;display: inline-block;width: 100px" >开始月份</div>
        <el-date-picker
        v-model="order.startDate"
        type="month"
        placeholder="选择开始月份"
        @change="monthChange"
        @disabled='true'
        style='position: relative;top:20px;left:40px'
        ></el-date-picker>
      </div>
    </div>
    <div style="width: 100%;position: relative;height: 1px;background-color: #D4DFE5;top:70px">
    </div>

    <div style="margin-top: 10px;z-index: 100;position: relative;width: 100%;top:70px;margin-left: 20px">

      <el-button @click="continueClass(index)" type="primary" style='margin-right: 20px;z-index: 100'>续课</el-button>
      <el-button @click="stopClass(index)" type="secondary" style='margin-right: 20px;z-index: 100' v-if='order.classStatus == 0'>停课</el-button>
      <el-button @click="stopClass(index)" type="warning" style='margin-right: 20px;z-index: 100' v-if='order.classStatus == 1'>恢复上课</el-button>
      <el-button @click="getAdmissibleChangeClass(index)" type="primary" style='margin-right: 20px;z-index: 100'>转班</el-button>
      <el-button @click="changeCourse(index)" type="secondary" style='margin-right: 20px;z-index: 100'>转课</el-button>
    </div>



  </el-row>
  <el-button @click="confirmQuit" type="warning" style='float: right' v-if='hasRight'>确认流失</el-button>
</el-button>

<el-row v-if='(student.quit == 1) && hasRight' style='margin-top: 50px'>
  <el-row :span="6" style="margin-top:10px;height:40px"><span style='width:2px;height:100%;background-color:rgb(52, 178, 211) ;color: rgb(52, 178, 211);margin-right: 3px'>_</span>
    流失罚款信息
    <el-button @click="showStaff = true" type='primary' style='height:30px;position: relative;top:0px;font-size: 14px;padding: 5px;margin-left:50px;display: inline-block;' >添加流失罚款人员
    </el-button>
  </el-row>

  <el-row v-if="penaltyList.length == 0" style='background-color: white;height:150px;margin-top: 10px;border-width: 1px;border-color: #D4DFE5;border-style: solid;'>
    <div style="color:#CACBCC;width: 100%;text-align: center;line-height: 150px;height: 150px">
      <el-button type='primary' @click='showStaff = true' >添加罚款人员</el-button>
    </div>
  </el-row>

  <el-row style='background-color:white;width: 100%;position: relative;border-width: 1px;border-color: #D4DFE5;border-style: solid;margin-bottom:20px;margin-top: 10px;border-width: 1px;border-color: #D4DFE5;border-style: solid;'  v-else>


  <div style="width: 100%;position: relative;height: 1px;background-color: #D4DFE5">
  </div>

  <div style="width: 100%;position: relative;">
    <div v-for='(commission,index) in penaltyList' style="margin-bottom:10px;height:60px;position: relative;">
      <div style="position: relative;left:30px;display: inline-block;width: 100px;height: 60px">{{commission.staff.name}}</div>
      <div style="position: relative;left:80px;color:#98A0A7;display: inline-block;width: 100px;height: 60px;line-height: 60px">罚款类型：</div>
      <el-select v-model="commission.type"  style='display: inline-block;left:255px;position:absolute;top:15px;width: 150px' >
        <el-option
        v-for="item in bonusTypes"
        :label="item.name"
        :value="item.value"
        ></el-option>
      </el-select>

                  <div style="display: inline-block;">
                    <div style="width: 120px;display: inline-block;position: relative;top:0;height: 60px;line-height: 60px;left:400px;color:#98A0A7;">罚金（元）:</div>
                    <el-input style="position: relative;width: 100px;display: inline-block;left:400px " v-model='commission.commission' type='number' min='0'> </el-input>
                  </div>
                  <button style="height:30px;width: 30px;background-color: #F6E4E7;border-style: solid;border-width: 1px;border-color: #FB6363;border-radius: 3px;position: absolute;top:20px;right:50px" @click="removeCommission(index)"><i class="el-icon-close" style="color: #FB6363;" ></i> 
                  </button>
                  <div style="width: 100%;position: relative;height: 1px;background-color: #D4DFE5;top:-9px"></div>
                </div>
              </div>
            </el-row>


            <el-button @click="confirmPenalty" type="warning" style='float: right;margin-top: 10px'>确认罚款</el-button>
          </el-button>

          <el-dialog title="员工" :visible.sync="showStaff" >
            <el-input placeholder="请输入员工姓名" v-model="search.staffName" size="small">
              <el-button slot="append" icon="el-icon-search" @click="searchStaff"></el-button>
            </el-input>
            <el-table :data="staffList" height="500">
              <el-table-column property="name" label="员工姓名"></el-table-column>
              <el-table-column  label="操作">
                <template slot-scope="scope">
                  <el-button @click="addStaff(scope.$index)" type="text">选择</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="showStaff = false">确认</el-button>
            </div>
          </el-dialog>
          <div></div>
        </el-row>

      </el-main>

    </el-tab-pane>

    <el-tab-pane label="学生资料" name='studentInfo2'>
      <el-main>
        <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;margin-bottom: 20px'>
          <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
          <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
          <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
          在读课程： {{courseCount}}</div>
          <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
            <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
          在读校区:  {{student.school.name}}</div>
          <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
            <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
          联系方式： {{parentInfo}}</div>
          <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
          </div>
        </el-row>


        <el-form  :model="student" label-width="80px" label-position="left"
        :rules="FormRules">

        <el-form-item label="姓名" prop="name">
          <el-input placeholder v-model="student.name" :disabled="studentDisabled"></el-input>
        </el-form-item>
        <el-form-item label="学号" >
          <el-input placeholder v-model="student.studentId" :disabled="studentDisabled"></el-input>
        </el-form-item>

        <el-form-item label="学生性别" prop="gender">
          <el-radio-group v-model="student.gender" :disabled="studentDisabled">
            <el-radio :label="0">男</el-radio>
            <el-radio :label="1">女</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="生日" >
         <el-date-picker
         v-model="student.birthday"
         type="date"
         placeholder="选择生日"
         :disabled="studentDisabled"
         ></el-date-picker>
         <!-- <el-input placeholder v-model.number="parents[index].age" :disabled="studentDisabled"></el-input> -->
       </el-form-item>

       <el-form-item label="在读学校" >
        <el-input placeholder v-model="student.publicSchool" :disabled="studentDisabled"></el-input>
      </el-form-item>

      <el-form-item label="家庭地址" >
        <el-input placeholder v-model="student.address" :disabled="studentDisabled"></el-input>
      </el-form-item>

      <el-form-item label="对内备注" >
        <el-input placeholder v-model="student.inRemark" :disabled="studentDisabled"></el-input>
      </el-form-item>
      <el-form-item label="对外备注">
        <el-input placeholder v-model="student.outRemark" :disabled="studentDisabled"></el-input>
      </el-form-item>
    </el-form>


  </el-main>
  <el-footer>
    <el-button type="primary" @click="submitStudent" :disabled="studentDisabled">提交</el-button>
    <el-button @click="editStudent">修改</el-button>
  </el-footer>
</el-tab-pane>

<el-tab-pane label="学生订单" name='studentOrder'>
  <el-main>
    <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;'>
      <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
      <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
      在读课程： {{courseCount}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
      在读校区:  {{student.school.name}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
      联系方式： {{parentInfo}}</div>
      <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
      </div>
    </el-row>

    <h3 style="display: inline-block;margin-top: 5vw">学生订单</h3>
    <el-table :data="order_data_list" border style="width: 100%">
      <el-table-column prop="name" label="课程"></el-table-column>
      <el-table-column prop="school.name" label="学校名称"></el-table-column>
      <el-table-column prop="payWay" label="扣费方式">
        <template slot-scope="scope">
          <span v-if='order_data_list[scope.$index].type==0'> 课时 </span>
          <span v-if='order_data_list[scope.$index].type==1'> 小时 </span>
          <span v-if='order_data_list[scope.$index].type==2'> 包月 </span>
        </template>
      </el-table-column>
      <el-table-column  label="充值数量">
        <template slot-scope="scope">
          {{order_data_list[scope.$index].numberTotal}}
        </template>
      </el-table-column>
      <el-table-column  label="金额(元)">
        <template slot-scope="scope">
          {{parseFloat(order_data_list[scope.$index].total - order_data_list[scope.$index].discount).toFixed(2)}}
        </template>


      </el-table-column>
      <el-table-column prop="memoIn" label="对内备注"></el-table-column>
      <el-table-column prop="memoOut" label="对外备注"></el-table-column>
      <el-table-column prop="created" label="创建时间"></el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="handleOrderClick(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
    background
    layout="total,sizes,prev, pager, next,jumper"
    :page-size="order_page_size"
    :current-page="order_current_page"
    :total="order_total"
    @current-change="handleCurrentChangeOrder"
    @size-change="handlerSizeChangeOrder"
    @next-click="handleNextPageOrder"
    @prev-click="handlePrevClickOrder"
    ></el-pagination>


  </el-main>

</el-tab-pane>


<el-tab-pane label="出勤记录" name='studentRecord'>
  <el-main>

    <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;'>
      <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
      <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
      在读课程： {{courseCount}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
      在读校区:  {{student.school.name}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
      联系方式： {{parentInfo}}</div>
      <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
      </div>
    </el-row>


    <h3 style="display: inline-block;margin-top: 5vw">出勤情况</h3>
    <el-table :data="student.records" border style="width: 100%;">
      <el-table-column prop="class.name" label="班级">
        <template slot-scope="scope">
          <a :href="'#/class-detail?class_id=' + scope.row.class._id">{{scope.row.class.name}}</a>
        </template>
      </el-table-column>

      <el-table-column prop="class.course.name" label="课程"></el-table-column>
      <el-table-column prop="time" label="时间"></el-table-column>
      <el-table-column prop="statusText" label="情况">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0" class="statusGreen">出席 </span>
          <span v-else-if="scope.row.status == 1" class="statusRed">旷课</span>
          <span v-else-if="scope.row.status == 2" class="statusBlue">迟到</span>
          <span v-else-if="scope.row.status == 3" class="statusYellow">请假</span>
          <span v-else>未知</span>
        </template>
      </el-table-column>

      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="handleDeleteClick(scope.row)" type="text" size="small">删除</el-button>
          <el-button @click="handleUpdateClick(scope.row)" type="text" size="small">更新状态</el-button>
        </template>

      </el-table-column>
    </el-table>
    <el-pagination
    background
    layout="total,sizes,prev, pager, next,jumper"
    :page-size="pageSize"
    :current-page="currentPage"
    :total="total"
    @current-change="handleCurrentChange"
    @size-change="handlerSizeChange"
    @next-click="handleNextPage"
    @prev-click="handlePrevClick"
    ></el-pagination>

  </el-main>

</el-tab-pane>

<el-tab-pane  label="学生备注消息" name="studentComment" >
  <el-main>
    <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;margin-bottom:20px'>
      <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
      <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
      在读课程： {{courseCount}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
      在读校区:  {{student.school.name}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
      联系方式： {{parentInfo}}</div>
      <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
      </div>
    </el-row>

    <h3 style="display: inline-block;margin-top: 0vw">学生备注消息</h3>
        <el-button type='primary' style='float: right' @click='showMessage = true'>新建消息</el-button>

    <el-table :data="studentComment" border style="width: 100%">
      <el-table-column  label="备注消息">
        <template slot-scope='scope'>
          <div style="white-space: pre">{{scope.row.comment}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="staff.name" label="备注人员"></el-table-column>
      <el-table-column prop="time" label="时间"></el-table-column>
      
    </el-table>

</el-main>

</el-tab-pane>

<el-tab-pane  label="学生学习计划" name="studentStudyPlan" >
  <el-main>
    <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;margin-bottom:20px'>
      <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
      <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
      在读课程： {{courseCount}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
      在读校区:  {{student.school.name}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
      联系方式： {{parentInfo}}</div>
      <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
      </div>
    </el-row>

    <h3 style="display: inline-block;margin-top: 0vw">学生学习计划</h3>
        <el-button type='primary' style='float: right' @click='showPlan = true'>新建计划</el-button>

    <el-table :data="studentStudyPlan" border style="width: 100%">
      <el-table-column  label="学习计划">
        <template slot-scope='scope'>
          <div style="white-space: pre">{{scope.row.comment}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="staff.name" label="备注人员"></el-table-column>
      <el-table-column prop="time" label="时间"></el-table-column>
      
    </el-table>

</el-main>

</el-tab-pane>

<el-tab-pane v-for='(item,index) in parents' :key="index" :label="'家长信息' + (index + 1) " :name="'tab' + index" >
  <el-main>

    <el-row :span="12" v-if='student != undefined' style='background-color: #F6FAFE;height:40px;margin-top:10px;line-height: 40px;padding-left:10px;position: relative;margin-bottom:20px'>
      <div style="font-size:18px;display: inline-block;">{{student.name}}</div>
      <div style="margin-left:3px;display: inline-block;font-size:15px">{{student.gender == 0 ? ' 男' : ' 女'}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px"> | <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(96, 186, 178); border-color: rgb(96, 186, 178); background-color: rgb(221, 248, 239);border-style: solid;border-width: 1px;border-radius: 3px">课</span> 
      在读课程： {{courseCount}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(153, 100, 245); border-color: rgb(188, 168, 255); background-color: rgba(188, 168, 255, 0.15);border-style: solid;border-width: 1px;border-radius: 3px">校</span>
      在读校区:  {{student.school.name}}</div>
      <div style="display: inline-block;margin-left: 10px;font-size:15px">| 
        <span style="margin-left:5px;background-color: red;display: inline-block;height:30px;width: 30px;text-align: center;position: relative;top:0px;line-height: 30px;color: rgb(52, 178, 211); border-color: rgb(96, 186, 178); background-color: rgb(182, 238, 251);border-style: solid;border-width: 1px;border-radius: 3px">联</span>
      联系方式： {{parentInfo}}</div>
      <div style="display: inline-block; height:40px;line-height: 40px;position: relative;float:right;right:50px">
      </div>
    </el-row>

    <el-form  :model="parents[index]" label-width="80px" label-position="left"
    :rules="FormRules">

    <el-form-item label="家长姓名" prop="name">
      <el-input placeholder v-model="parents[index].name" :disabled="parentsDisabled"></el-input>
    </el-form-item>

    <el-form-item label="手机" prop="cellphone">
      <el-input placeholder v-model.number="parents[index].cellphone" :disabled="parentsDisabled"></el-input>
    </el-form-item>

    <el-form-item label="年龄" prop="age">
      <el-input placeholder v-model.number="parents[index].age" :disabled="parentsDisabled" type='number' step='1'></el-input>
    </el-form-item>

    <el-form-item label="职业" prop="job">
      <el-input placeholder v-model="parents[index].job" :disabled="parentsDisabled"></el-input>
    </el-form-item>

    <el-form-item label="关系" prop="relation">
      <!-- <el-input placeholder v-model="parents[index].relation" :disabled="parentsDisabled"></el-input> -->
      <el-select v-model="parents[index].relation" placeholder="关系"  :disabled='parentsDisabled' @change='hahaha'>
        <el-option
        v-for="item in parentsOption"
        :label="item"
        :value="item"
        >
      </el-option>
    </el-select>
  </el-form-item>

  <el-form-item label="生日" prop="birthday">
    <el-date-picker v-model="parents[index].birthday" type="date"
    placeholder="选择家长生日" :disabled="parentsDisabled"></el-date-picker>
  </el-form-item>
</el-form>

</el-main>
<el-footer style="text-align: center">
  <el-button type="primary"  @click="submitParents(index)" :disabled="parentsDisabled">提交</el-button>
  <el-button @click="editParents">修改</el-button>
</el-footer>


</el-tab-pane>



</el-tabs>
</div>
</d2-container>
</template>

<style>
.statusGreen{
  color :green;

}
.statusRed{
  color:red;
}
.statusBlue{
  color:blue;
}
.statusYellow{
  color:black;
}
</style>


<script>
  import request from "@/plugin/axios";
  import formatTime from "@/libs/util.formatTime";
  import {mapState} from "vuex";

  export default {
    data() {
      return {
        classInName : '',
        classInID : undefined,
        courseOut : {typeText:'',leftAmount : '',type:0,class:{name:''},course:{}},
        courseTransfer : {class:undefined,type:undefined,numberTotal : 0},
        courseTransferList : [],
        courseTransferIndex: undefined,
        search :{staffname : ''},
        staffList : [],
        showStaff :false,
        studentComment : [],
        showMessage : false,
        message : '',
        reimbursedialogShow :false,
        option:{
          //状态 0出席，1旷课，2迟到，3请假
          studentRecordStatus:[
          {name:'出席', value:0},
          {name:'旷课', value:1},
          {name:'迟到', value:2},
          {name:'请假', value:3}
          ],
          classOption:[],
          classInOption:undefined,
          classChangeOption:undefined
        },
        FormRules: {
          name: [
          {required: true, message: '请输入姓名', trigger: 'blur'},
          {min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur'}
          ],
          studentId: [
          { message: '请输入学号', trigger: 'blur'}
          ],
          gender: [
          {required: true, message: '请选择学生性别', trigger: 'blur'}
          ],
          age: [
          { message: '请输入年龄', trigger: 'blur'},
          {type: 'number', min: 5, max: 100, message: '年龄范围在5-100之间', trigger: 'blur'}

          ],
          school: [
          {required: true, message: '请选择所在校区', trigger: 'blur'}
          ],
          cellphone: [
          {required: true, message: '手机号不能为空', trigger: 'blur'},
          {type: 'number', message: '请输入11位合法手机号', trigger: 'blur'}
          ],
          cellphone2: [
          {type: 'number', message: '请输入11位合法手机号', trigger: 'blur'}
          ],
          relation :[
          {required:'true',message:'请输入关系'}
          ],
          birthday: [
          {type: 'date', message: '请选择出生日期', trigger: 'blur'}
          ]
        },
        order_data_list:[],
        studentId: undefined,
        // parentsId: undefined,
        bonusTypes : [{value:-1,name:'流失罚款'}],
        dialogVisibleStatus:false,
        dialogVisibleClass:false,
        dialogVisibleChangeClass:false,
        dialogVisibleRemoveClass:false,
        dialogStudentStatus : false,
        dialogVisibleChangeCourse : false,
        showPlan : false,
        studentStudyPlan : [],
        parentInfo : '',
        reimburseAmount:undefined,
        courseCount : 0,
        courseOrder : [],
        penaltyList : [],
        student: {
          name: undefined,
          studentId: undefined,
          gender: undefined,
          cellphone: undefined,
          birthday: undefined,
          inRemark: undefined,
          outRemark: undefined,
          address:undefined,
          publicSchool:undefined,
          class:undefined,
          balance:undefined,
          school : {name:''},
          quit : undefined
        },
        hasRight :false,
        plan : '',
        parents: [],
        studentDisabled: false,
        parentsDisabled: false,
        total: 100,
        pageSize: 20,
        currentPage: 1,
        order_total:undefined,
        order_current_page:1,
        order_page_size:20,
        order_query_search:{},
        dialog_id:undefined,
        dialog_status:undefined,
        wait_add_class:undefined,
        class_in_chosen:undefined,
        class_ready_in:undefined,
        class_ready_leave:undefined,
        courseTransferClassList : [],
        parentsOption : ['妈妈','爸爸','爷爷','奶奶','外婆','外公','其他']
      };
    },
    computed: {
      ...mapState('d2admin/user', ['info']),
    },
    methods: {

      getAdmissibleClass() {
        request({
          url: "/class/getClassList",
          method: "post",
          data: {}
        }).then(res => {
          if (res.code == 200) {
            this.option.classOption = res.data.class
            this.dialogVisibleClass = true
          }
        })
      },

      getAdmissibleChangeClass(index) {
        request({
          url: "/class/getAdmissibleClassList",
          method: "post",
          data: {student:this.studentId,course:this.courseOrder[index].course._id}
        }).then(res => {
          if (res.code == 200) {
            this.class_in_chosen = this.courseOrder[index].class._id
            this.classInName = this.courseOrder[index].class.name
            this.option.classChangeOption = res.data.classChangeOption
            this.dialogVisibleChangeClass = true
          }
        })
      },

      getAdmissibleExitClass() {
        request({
          url: "/class/getAdmissibleClassList",
          method: "post",
          data: {student:this.studentId}
        }).then(res => {
          if (res.code == 200) {
            this.option.classInOption = res.data.classInOption
          }
        })
      },

      removeFromClass(){

        this.$confirm('退学后学生自动退出全部班级，默认为学生流失。 页面可操作退款。 如需单独订单退款，请去订单页面操作。','确定要退学吗？',{
          confirmButtonText : '确定',
          cancelButtonText : '取消'
        }).then(res =>{
          request({
            url: "/student/stopStudent",
            method: "post",
            data: {student:this.studentId}
          }).then(res => {
            if (res.code == 200) {
              this.load()
              this.$message({
                message: "退学成功"
              });
            }
          })
        }).catch(res =>{

        })
      },


      restoreStudent(index){

        this.$confirm('','确定要复课吗？',{
          confirmButtonText : '确定',
          cancelButtonText : '取消'
        }).then(res =>{
          console.log(res,'ab')
          // request({
          //   url: "/student/restoreStudent",
          //   method: "post",
          //   data: {id:this.studentId}
          // }).then(res => {
          //   console.log('done')
          // })
          request({
            url: "/student/restoreStudent",
            method: "post",
            data: {student:this.studentId}
          }).then(res => {

            if (res.code == 200) {
              this.load()
                  // this.getstudentOne(this.$route.query.id);

              this.$message({
                message: "复课成功！"
              });
            }
          })
        }).catch(res =>{
        })
      },

      updateStudentNewStudent(index){

        this.$confirm('','确定确认该学生转卡吗？',{
          confirmButtonText : '确定',
          cancelButtonText : '取消'
        }).then(res =>{
          request({
            url: "/student/updateStudentNewStudent",
            method: "post",
            data: {id:this.studentId}
          }).then(res => {
            if (res.code == 200) {
              this.$message({
                message: "确认成功！"
              });
              this.getstudentOne(this.studentId)
            }
          })
        }).catch(res =>{

        })
      },

      restoreClass(index){

        this.$confirm('','确定要复课吗？',{
          confirmButtonText : '确定',
          cancelButtonText : '取消'
        }).then(res =>{
          request({
            url: "/student/restoreClass",
            method: "post",
            data: {student:this.studentId,course:this.courseOrder[index]._id}
          }).then(res => {
            if (res.code == 200) {
              this.$message({
                message: "复课成功！"
              });
            }
          })
        }).catch(res =>{

        })
      },

      studentStatusChange(){
        request({
          url: "/student/studentStatusChange",
          method: "post",
          data: {student:this.studentId,status:this.student.status == 0 ? 1 : 0}
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              message: "更新成功"
            });
            this.student.status = this.student.status == 0 ? 1 : 0
            this.dialogStudentStatus = false
          }
        })
      },

      studentStatusChangeShow(){
        this.dialogStudentStatus = true
      },


      handleUpdateClick(e) {
        this.dialogVisibleStatus = true
        this.dialog_id = e._id
      },

      updateStudentRecord() {
        request({
          url: "/student/updateStudentRecord",
          method: "post",
          data: {_id: this.dialog_id, status: this.dialog_status}
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              message: "更新成功"
            });
            this.$router.go(0)
            this.dialogVisibleStatus = false
          }
        });
      },


      addStudentIntoNewClass() {
        request({
          url: "/student/addStudentToClass",
          method: "post",
          data: {student: this.studentId,class:[this.wait_add_class]}
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              message: "成加入新班级"
            });
            this.$router.go(0)
            this.dialogVisibleClass = false
          }
        });
      },

      moveStudentToOtherClass() {
        if (this.class_ready_in == undefined){
          this.$alert('','请选择转入班级')
          return false
        }
        if (this.class_ready_in == this.class_in_chosen){
          this.$alert('','该学生已经在改班级中')
          return false
        }
        let index = this.courseOrder.map(function(e){return e.class._id}).indexOf(this.class_in_chosen)
        let classout = this.class_in_chosen
        if (this.class_in_chosen == undefined){
          classout = 'none'
        }
        request({
          url: "/student/moveStudentToOtherClass",
          method: "post",
          data: {student: this.studentId,removeClass:classout,joinClass:this.class_ready_in,orderid : this.courseOrder[index]._id}
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              message: "成加转入新班级"
            });

            this.class_ready_in = undefined
            this.class_in_chosen = undefined
            this.dialogVisibleChangeClass = false
            // this.$router.go(0)
            this.getStudentCourses()
          }
        });
      },
      changeCourseConfirm(){
        // check coursein info, check amount , check proft 
        if (this.courseTransfer.type == undefined){
         this.$alert('','请选择转入课程')
         return false
       }
       if (this.courseTransfer.profit < 0){
        this.$alert('','补价不能小于0元')
        return false
      }

      request({
        url: "/student/changeCourse",
        method: "post",
        data: {student: this.studentId,courseOut:this.courseOut._id,courseIn:this.courseTransfer,staff:this.staff}
      }).then(res => {
        if (res.code == 200) {
          this.$message({
            message: "成加转入新课程"
          });

          this.dialogVisibleChangeCourse = false
            // this.courseOut = undefined
            this.courseTransfer = {class:undefined,type:undefined,numberTotal : 0}
            this.courseTransferIndex = undefined
            // this.courseTransferList
            this.getStudentCourses()
          }
        });


    },

    cancelChangeCourse(){
      this.dialogVisibleChangeCourse = false
      this.courseTransferIndex = undefined
      this.courseTransfer = {class:undefined,type:undefined,numberTotal : 0}

      this.courseTransferClassList = []
    },

    exitFromClass() {

      request({
        url: "/student/removeStudentFromClass",
        method: "post",
        data: {student: this.studentId,class:[this.class_ready_leave]}
      }).then(res => {
        if (res.code == 200) {
          this.$message({
            message: "成功退出该班级"
          });
          this.$router.go(0)
          this.dialogVisibleRemoveClass = false
        }
      });
    },

    handleClick(e) {
      this.$router.push({path: '/student-record?id=' + e._id})
    },


    handleOrderClick(e) {
      this.$router.push({path: '/course-order-detail?id=' + e._id})
    },


    handleCurrentChange(currentPage) {
      this.currentPage = currentPage
      this.dataSearch.page = this.currentPage;
      this.dataSearch.pageSize = this.pageSize;
      this.getstudentRecord(this.studentId);
    },
    handlerSizeChange(pageSize) {
      this.pageSize = pageSize
      this.dataSearch.page = this.currentPage;
      this.dataSearch.pageSize = this.pageSize;
      this.getstudentRecord(this.studentId);
    },
    handleNextPage() {
      this.currentPage = this.currentPage + 1
      this.dataSearch.page = this.currentPage;
      this.dataSearch.pageSize = this.pageSize;
      this.getstudentRecord(this.studentId);
    },
    handlePrevClick() {
      this.currentPage = math.max(0, this.currentPage - 1)
      this.dataSearch.page = this.currentPage;
      this.dataSearch.pageSize = this.pageSize;
      this.getstudentRecord(this.studentId);
    },

    handleDeleteClick(e) {

      this.$confirm("此操作将删除该课程, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        request({
          url: "/student/deleteStudentRecord",
          method: "post",
          data: {_id: e._id}
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              message: "删除成功"
            });
            this.getstudentRecord(this.studentId);
          }
        });

      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除"
        });
      });
    },
    getstudentOne(id) {
      request({
        url: "/student/getStudentOne",
        method: "post",
        data: {id: id}
      }).then(res => {
        console.log(res)
        if (res.code == 200) {
          this.student = res.data
            // this.studentId = res.data._id
            // this.student.name = res.data.name
            // this.student.class = res.data.class
            // this.student.studentId = res.data.studentId
            // this.student.gender = res.data.gender
            // this.student.cellphone = res.data.cellphone
            // this.student.birthday = res.data.birthday
            // this.student.inRemark = res.data.inRemark
            // this.student.remainingHours = res.data.remainingHours
            // this.student.credit = res.data.credit
            // this.student.outRemark = res.data.outRemark
            // this.student.status = res.data.status
            // this.student.balance = res.data.balance
            // this.student.publicSchool = res.data.publicSchool
            // this.student.address = res.data.address
          }
          this.getstudentRecord(this.studentId);
          this.getStudentCourses(this.studentId)
          if (this.student.quit == 1){
            this.getPenaltyList()
          }
          // 返回数据
        });
    },

    addParentTab(){
      if (this.studentId != undefined){
          this.parentsDisabled = false;
          this.parents.push({
            name: undefined,
            cellphone: undefined,
            birthday: undefined,
            age: undefined,
            job: undefined,
            relation: undefined
          })
        }
    },


    reimbursedialog(){
        this.reimbursedialogShow = true
        let amountx = 0
        for (var i = 0 ; i < this.courseOrder.length ; i++){
          console.log(this.courseOrder[i].amountx,'nnn')
          let unitPrice = (this.courseOrder[i].total - this.courseOrder[i].discount) / this.courseOrder[i].numberTotal
          amountx += unitPrice * this.courseOrder[i].amountx
        }

        amountx = parseFloat(amountx).toFixed(1)

        this.reimburseAmount = amountx

    },

    handleTabsEdit(index){
      if (index == null){
        if (this.studentId != undefined){
          this.parentsDisabled = false;
          this.parents.push({
            name: undefined,
            cellphone: undefined,
            birthday: undefined,
            age: undefined,
            job: undefined,
            relation: undefined
          })
        }
      }
      else if (index.indexOf('tab') == -1){
      }

      else{
        let index2 = parseInt(index.replace('tab',''))
        if (this.parents[index2]._id != undefined){
          this.$confirm("确定要删除该家长信息吗？", "", {
            confirmButtonText: "确定",
            cancelButtonText: '取消',
            type: 'info'
          }).then((value) => {
            console.log(value,'vava')
            if (value){
                                    // post to delete this parent
                                    request({
                                      url: 'parent/deleteParents',
                                      method: "post",
                                      data: {id:this.parents[index2]._id}
                                    }).then(res => {
                                      if (res.code == 200) {
                                        this.parents.splice(index2)
                                        if (this.parents.length > 0){
                                          this.paneChose = 'tab0'
                                        }
                                        else{
                                          this.paneChose = 'studentInfo'
                                        }
                                      }}
                                      )
                                  }

                                }).catch((value) => {
                                // this.studentId = undefined;
                                // this.$router.push({path: "/student-list"})
                              })
                              }
                              else{
                                this.parents.splice(index2)
                                if (this.parents.length > 0){
                                  this.paneChose = 'tab0'
                                }
                                else{
                                  this.paneChose = 'addStudent'
                                }


                              }
                            }
                          },


                          goCharge(){
                            this.$router.push({path:'/charge-order-new?studentId=' + this.studentId})
                          },

                          getstudentRecord(id) {
                            request({
                              url: "/student/getStudentRecord",
                              method: "post",
                              data: {id: id, offset: (this.currentPage - 1) * this.pageSize, pageSize: this.pageSize}
                            }).then(res => {
                              if (res.code == 200) {
                                for (var i = 0; i < res.data.records.length; i++) {
                                  res.data.records[i].time = formatTime.formatTime(res.data.records[i].createdAt)
                                }
                                this.student.records = res.data.records
                                this.total = res.data.total
                                this.currentPage = res.data.currentPage;
                              }
          // 返回数据
        });
                          },
                          changeCourse(index){
                            if (this.courseOut.type ==2){
                              this.$alert('','包月课程不能转课')
                              return false
                            }
                            if (this.courseOut.numberTotal <=0){
                              this.$alert('','换算数字不能等于0')
                              return false
                            }
                            this.courseOut = this.courseOrder[index]
                            this.courseOut.nameText = this.courseOut.course.name + '(' + this.courseOut.course.duration + '小时)'
                            if (this.courseOut.type == 0){
                              this.courseOut.typeText = '1课时=' + this.courseOut.course.pricePerClass + '元'
                              this.courseOut.leftAmount = this.courseOut.numberOfClasses
                            }
                            else if (this.courseOut.type == 1){
                              this.courseOut.typeText = '1小时=' + this.courseOut.course.pricePerHour + '元'
                              this.courseOut.leftAmount = this.courseOut.numberOfHours
                            }


                            request({
                              url: "/course/getCourseList",
                              method: "post",
                              data: {school:this.school,pageSize:10000}
                            }).then(res => {
                              this.courseTransferList = res.data.course
                            })
                            this.dialogVisibleChangeCourse = true
                          },

                          getParentsByStudent(id) {
                            request({
                              url: "/parent/getParentsByStudent",
                              method: "post",
                              data: {student: id}
                            }).then(res => {
                              if (res.code == 200) {
                                console.log(res.data,'dsds')
                                if (res.data.length > 0) {

                                  let temp = ''
                                  for (var i = 0 ; i < res.data.length ; i++){
                                    temp += res.data[i].cellphone + ' (' + res.data[i].name + ' ' + res.data[i].relation + ')'
                                    if (i != res.data.length - 1){
                                      temp += ', '
                                    }
                                  }
                                  this.parentInfo = temp


                                  this.parents = this.parents.concat(res.data)

              // this.parentsId = res.data[0]._id
              // this.parents.name = res.data[0].name
              // this.parents.cellphone = res.data[0].cellphone
              // this.parents.birthday = res.data[0].birthday
              // this.parents.age = res.data[0].age
              // this.parents.job = res.data[0].job
              // this.parents.relation = res.data[0].relation
            }
          }
          // 返回数据
        });
                          }
                          ,
                          submitStudent() {
                            let url = "/student/updateStudent";
                            let data = {};
                            data.student = this.studentId;
                            data.name = this.student.name;
                            data.studentId = this.student.studentId;
                            data.gender = this.student.gender;
                            data.address = this.student.address;
                            data.cellphone = this.student.cellphone;
                            data.birthday = this.student.birthday;
                            data.publicSchool = this.student.publicSchool;
                            data.address = this.student.address;
                            data.inRemark = this.student.inRemark;
                            data.outRemark = this.student.outRemark;
                            data.isDelete = this.student.isDelete;
                            request({
                              url: url,
                              method: "post",
                              data: data
                            }).then(res => {
                              if (res.code == 200) {

                                this.load()
                                this.paneChose = 'studentInfo2'
                                this.$alert("", "修改学生信息成功", {
                                  confirmButtonText: "确定"
                                });
            // this.studentId = res.data._id;
          }
          // 返回数据
        });
                          }
                          ,
                          submitParents(index) {
                            console.log(index,'asd')
                            let url = ''
                            if (this.parents[index]._id != undefined){
                              url = "/parent/updateParents";
                            }
                            else{
                              url = "/parent/addParents";
                            }
                            let data = this.parents[index]
                            data.student = [this.studentId]
                            request({
                              url: url,
                              method: "post",
                              data
                            }).then(res => {
                              if (res.code == 200) {
                                this.parentsDisabled = true;
                                this.$alert("", "修改家长信息成功", {
                                  confirmButtonText: "确定"
                                });
            // this.parents[index]._id = res.data._id;
          }
          // 返回数据
        });
                          }
                          ,
                          editStudent() {
                            this.studentDisabled = false;
                          }
                          ,
                          editParents() {
                            this.parentsDisabled = false;
                          },

                          changeCourseAmount(event){
                            this.courseTransfer.numberTotal = event

                            let total = 0
                            if (this.courseOut.type == 0){
                              total += this.courseOut.numberOfClasses * this.courseOut.course.pricePerClass
                            }
                            else if (this.courseOut.type == 1){
                              total += this.courseOut.numberOfHours * this.courseOut.course.pricePerHour
                            }
                            let diff = parseFloat((this.courseTransfer.type == 0 ? this.courseTransfer.pricePerClass : this.courseTransfer.pricePerClass) * event - total).toFixed(2)
                            this.courseTransfer.total = diff
                            this.courseTransfer.profit = parseFloat(this.courseTransfer.total - this.courseTransfer.discount).toFixed(2)

                            this.courseTransferList.push({})
                            this.courseTransferList.splice(this.courseTransferList.length-1,1)
                          },
                          changeCourseDiscount(event){
                            this.courseTransfer.discount = event
                            this.courseTransfer.profit = parseFloat(this.courseTransfer.total - this.courseTransfer.discount).toFixed(2)

                            this.courseTransferList.push({})
                            this.courseTransferList.splice(this.courseTransferList.length-1,1)
                          },

                          hahaha(){
                            this.courseTransferList.push({})
                            this.courseTransferList.splice(this.courseTransferList.length-1,1)
                          },


                          changeCourseSelect(){
                            this.courseTransfer = {class:undefined,type:undefined,numberTotal : 0}
                            this.courseTransfer = this.courseTransferList[this.courseTransferIndex]
                            this.courseTransfer.pays = [{type:0,name:'1课时=' + this.courseTransfer.pricePerClass + '元'},{type:1,name:'1小时=' + this.courseTransfer.pricePerHour + '元'}]
                            this.courseTransfer.type = this.courseOut.type

        // calculate money 
        let total = 0
        if (this.courseOut.type == 0){
          total += this.courseOut.numberOfClasses * this.courseOut.course.pricePerClass
        }
        else if (this.courseOut.type == 1){
          total += this.courseOut.numberOfHours * this.courseOut.course.pricePerHour
        }

        let numberTotal = Math.ceil(total / (this.courseTransfer.type == 0 ? this.courseTransfer.pricePerClass : this.courseTransfer.pricePerClass))
        let diff = parseFloat((this.courseTransfer.type == 0 ? this.courseTransfer.pricePerClass : this.courseTransfer.pricePerClass) * numberTotal - total).toFixed(2)

        this.courseTransfer.numberTotal = numberTotal
        this.courseTransfer.total = diff
        this.courseTransfer.discount = 0
        this.courseTransfer.profit = diff
        this.courseTransfer.leftAmount = this.courseOut.leftAmount
        //total / (this.courseTransfer.type == 0 ? this.courseTransfer.pricePerClass : this.courseTransfer.pricePerClass)

        request({
          url: '/class/getClassList',
          method: "post",
          data: {course:this.courseTransfer._id,school:this.school,pageSize:99999}
        }).then(res => {
          if (res.code == 200) {
            this.courseTransferClassList = res.data.class
          }
          // 返回数据
        });
      },


      addStaff(index){
        this.penaltyList.push(
        {
          staff : this.staffList[index],
          commission : 0,
          type : -1
        }
        )
      },

      getStudentMessage(){
        request({
          url: '/student/getStudentComment',
          method: "post",
          data: {student:this.studentId}
        }).then(res => {
          if (res.code == 200) {
            res.data.forEach(value=>{value.time = formatTime.formatTime(value.createdAt)})
            this.studentComment = res.data
          }
        });
      },

      getStudentStudyPlan(){
        request({
          url: '/student/getStudentStudyPlan',
          method: "post",
          data: {student:this.studentId}
        }).then(res => {
          if (res.code == 200) {
            res.data.forEach(value=>{value.time = formatTime.formatTime(value.createdAt)})
            this.studentStudyPlan = res.data
          }
        });
      },


      searchStaff() {

        request({
          url: "/staff/getStaffList",
          method: "post",
          data: {
            page: 1,
            pageSize: 100,
            name: this.search.staffName,
            school: this.school
          }
        }).then(res => {
          this.staffList = res.data.staff;
          this.searchStaffCount = res.data.count;
        });
      },

      handleCurrentChangeOrder(currentPage) {
        this.order_current_page = currentPage
        this.order_query_search.page = this.order_current_page;
        this.order_query_search.pageSize = this.order_page_size;
        this.getOrderDataList(this.order_query_search);
      },
      handlerSizeChangeOrder(pageSize) {
        this.order_page_size = pageSize
        this.order_query_search.page = this.order_current_page;
        this.order_query_search.pageSize = this.order_page_size;
        this.getOrderDataList(this.order_query_search);
      },
      handleNextPageOrder() {
        this.order_current_page = this.order_current_page + 1
        this.order_query_search.page = this.order_current_page;
        this.order_query_search.pageSize = this.order_page_size;
        this.getOrderDataList(this.order_query_search);
      },
      handlePrevClickOrder() {
        this.order_current_page = this.order_current_page - 1
        this.order_query_search.page = this.order_current_page;
        this.order_query_search.pageSize = this.order_page_size;
        this.getOrderDataList(this.order_query_search);
      },

      confirmQuit(){
        this.$confirm('确认后可以添加流失罚款。','确认该学生流失吗？',{
          confirmButtonText:'确定',
          cancelButtonText : '取消',
          type: "warning"
        }).then((value)=>{
          request({
            url: "/student/confirmStudentQuit",
            method: "post",
            data: {student:this.studentId}
          }).then(res => {
            this.getstudentOne(this.studentId)
          })
        })
      },


      confirmPenalty(){
        this.$confirm('如果需要修改金额，请和财务确认是否已经扣款后修改。','确认老师流失罚款吗？',{
          confirmButtonText:'确定',
          cancelButtonText : '取消',
          type: "warning"
        }).then((value)=>{
          request({
            url: "/staffCommission/addPenalty",
            method: "post",
            data: {student:this.studentId,penaltyList : this.penaltyList,school:this.school}
          }).then(res => {
            this.getstudentOne(this.studentId)
          })
        })},

        getPenaltyList(){
          request({
            url: "/staffCommission/getPenaltyList",
            method: "post",
            data: {student:this.studentId}
          }).then(res => {
            if (res.code == 200){
              this.penaltyList = res.data == undefined ? [] : res.data
            }

          })
        },

        reimburseCancel(){
            this.reimbursedialogShow = false
            this.reimburseAmount = undefined
        },

        reimburseConfirm(){
            let data = {}
            data.studentId = this.studentId
            data.orders = this.courseOrder.map(e=>{return e._id})
            data.amount = this.reimburseAmount
            data.staff = this.staff
            data.school = this.school
            request({
            url: "/courseOrder/reimburseCourse",
            method: "post",
            data: data
          }).then(res => {
              if (res.code == 200){
                this.reimbursedialogShow = false
                this.reimburseAmount = 0
                this.courseOrder = []
                this.$message('退款成功！')
                this.load()
              }

          })
        },

        getOrderDataList(data) {
          if (this.teacher){
            data.teacher = this.teacher
          }

          request({
            url: "/courseOrder/getCourseOrderList",
            method: "post",
            data: data
          }).then(res => {
            this.order_total = res.data.total;
            this.order_current_page = res.data.currentPage;
            this.order_data_list = []
            this.order_data_list = res.data.courseOrder
            this.order_data_list.forEach((item,index)=>{
              this.order_data_list[index].name = item.course.name
              this.order_data_list[index].payWay = item.payWay == 1 ? '按时长收费':'按节数收费'
                

              this.order_data_list[index].created = this.formatDate(item.createdAt)
            })
          })
        },
        getStudentCourses() {
          let temp = {}
          temp.student = this.student._id
          temp.continue = 0
          request({
            url: "/courseOrder/getStudentCourseOrder",
            method: "post",
            data: temp
          }).then(res => {
            console.log(res.data.courseOrder.length,'sss')
            for (var i = 0 ; i < res.data.courseOrder.length ; i++){
              res.data.courseOrder[i].class = res.data.courseOrder[i].class == null ? {name:'暂无'} : res.data.courseOrder[i].class
              res.data.courseOrder[i].valid = res.data.courseOrder[i].valid == 1 ? true : false
              if (res.data.courseOrder[i].type == 0){
                  res.data.courseOrder[i].amountx = res.data.courseOrder[i].numberOfClasses
                   res.data.courseOrder[i].unitPrice = parseFloat(res.data.courseOrder[i].total / (res.data.courseOrder[i].numberTotal || 1)).toFixed(1)
                   res.data.courseOrder[i].classType = '课时'
                }
                else if (res.data.courseOrder[i].type == 1){
                  res.data.courseOrder[i].amountx = res.data.courseOrder[i].numberOfHours
                  res.data.courseOrder[i].unitPrice = parseFloat(res.data.courseOrder[i].total / (res.data.courseOrder[i].numberTotal || 1)).toFixed(1)
                  res.data.courseOrder[i].classType = '小时'
                }
                else if (res.data.courseOrder[i].type == 2){
                  let ttt = new Date().getTime()
                  let startDate = new Date(res.data.courseOrder[i].startDate).getTime()
                  let rrr = startDate + 3600000 * 24 * 30 * res.data.courseOrder[i].numberOfMonths - ttt
                  console.log(rrr,'rrrr')

                  let sss = parseFloat(rrr / 3600000 / 24 / 30).toFixed(1)
                  if (startDate >= ttt){
                    sss = res.data.courseOrder[i].numberOfMonths
                  }
                  else if (sss < 0){
                    sss = 0
                  }
                  res.data.courseOrder[i].amountx = sss
                  res.data.courseOrder[i].unitPrice = parseFloat(res.data.courseOrder[i].total / (res.data.courseOrder[i].numberTotal ||1)).toFixed(1)
                  res.data.courseOrder[i].classType = '包月'
                }
            }
            this.courseOrder = res.data.courseOrder
            this.courseCount = new Set(res.data.courseOrder.map(function(e){return e.course._id})).size

          })
        },
        formatDate(date) {
          date = new Date(date);
          let year = date.getFullYear();
          let month = date.getMonth() + 1;
          let day = date.getDate();
          return [year, month, day].map(this.formatNumber).join("-");
        },
        formatNumber(n) {
          n = n.toString();
          return n[1] ? n : "0" + n;
        },

        removeCommission(index){
          if (this.penaltyList[index]._id != undefined){
      //confirm delte this commission
      this.$confirm('如果已经收取罚款，请联系相关人员进行下一步操作','需要删除该罚款吗？',{
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then((value) => {
        request({
          url: "/staffCommission/removeStaffPenalty",
          method: "post",
          data: {id:this.penaltyList[index]._id}
        }).then(res => {
          if (res.code == 200){
            this.$alert('','删除成功',{
              confirmButtonText :'确定',
              type: 'info'
            }).then((value) =>{
              this.penaltyList.splice(index,1)


            })
          }
        });
      })
      .catch(()=>{
          // this.getCourseOrderOne(this.id)
        })

    }
    else{
      this.penaltyList.splice(index,1)

    }
  },
  newMessage(){
    if (this.message == ''){
      this.$alert('消息不能为空','')
    }
    else{
      request({
        url: "/student/newStudentComment",
        method: "post",
        data: {student:this.studentId,comment : this.message, staff:this.staff}
      }).then(res => {
        this.showMessage = false
        if (res.code == 200){
          this.message = ''
          this.$message('添加成功！')
          this.getStudentMessage()
        }
        else{
          this.$message('添加失败')
        }
    })
  }},

    newStudyPlan(){
    if (this.plan == ''){
      this.$alert('消息不能为空','')
    }
    else{
      request({
        url: "/student/newStudentStudyPlan",
        method: "post",
        data: {student:this.studentId,comment : this.plan, staff:this.staff}
      }).then(res => {
        this.showPlan = false
        if (res.code == 200){
          this.plan = ''
          this.$message('添加成功！')
          this.getStudentStudyPlan()
        }
        else{
          this.$message('添加失败')
        }
    })
  }},

  buyOrder(){
    this.refresh = true
    this.$router.push({path:'/main-order?student=' + this.studentId})
  },

  continueClass(index){
    this.refresh = true
    this.$router.push({path:'/main-order?student=' + this.studentId + '&course=' + this.courseOrder[index].course._id  + (this.courseOrder[index].class.name == '暂无' ? '' : '&class=' + this.courseOrder[index].class._id)})
  },

  stopClass(index){
    let message = ''
    if (this.courseOrder[index].classStatus == 0){
      message = '确认要停止该课程吗？'
    }
    else{
      message = '确认要恢复该课程吗？'
    }
    this.$confirm('',message,{
      confirmButtonText : '确认',
      cancelButtonText : '取消'
    }).then(res =>{
      request({
        url: "/courseOrder/courseStatusChange",
        method: "post",
        data: {id:this.courseOrder[index]._id,status : this.courseOrder[index].classStatus == 0 ? 1 : 0}
      }).then(res => {
        if (res.code == 200){
          this.courseOrder[index].classStatus = this.courseOrder[index].classStatus == 0 ? 1 : 0
        }

      })
    })
  },
  load(){
      if (this.$route.query.id != undefined) {
    this.studentId = this.$route.query.id
    this.school = this.info.school[0]._id
    this.staff = this.info.staff == undefined ? null : this.info.staff._id
    this.staffname = this.info.staff == undefined ? '' : this.info.staff.name
    this.order_query_search.page = this.order_current_page;
    this.order_query_search.pageSize = this.order_page_size;
    this.order_query_search._id = this.$route.query.id
    this.order_query_search.student = this.$route.query.id
    this.getstudentOne(this.$route.query.id);
    this.getParentsByStudent(this.$route.query.id);
    this.getOrderDataList(this.order_query_search);
    this.studentDisabled = true;
    this.parentsDisabled = true;
    this.getAdmissibleExitClass();
    this.getStudentMessage()
    this.getStudentStudyPlan()
    this.paneChose = 'studentInfo'
    this.rights = this.info.rights.map(function(e){return e.name})
    let index1 = this.rights.indexOf('root') != -1
    let index5 = this.rights.indexOf('校长') != -1
    let index2 = this.rights.indexOf('授课老师') != -1
    let index4 = this.rights.indexOf('授课老师') != -1
    index1 = index1 || index5
    index2 = (index2 || index4)
    let index3 = this.rights.indexOf('教务中心') != -1
    if (index1 || index3){
      this.hasRight = true
    }
    if ((!index1) && (index2)){
      if (!index3){
        this.teacher = true
      }
    }
  }
  }

},
beforeRouteEnter(to,from,next){
            if (to.meta.refresh == 'a'){
                to.meta.refresh = undefined
                next(v=>{
                v.load()
                })
            }
            else{
                next()
            }

        },
  beforeRouteLeave(to,from,next){
        if (this.refresh){
          to.meta.refresh = 'a'
          this.refresh = false
        }
        next()
      },

created() {
  this.load()

}
}


</script>
